<script setup lang="ts">
  import router from "@/router";
  import {login} from "@/api/user"
  import {reactive,markRaw} from "vue";
  import {setToken} from "@/utils/auth";
  import { UserStore } from "@/store/modules/user";

  const userStore = UserStore();

  const account = reactive({username:"admin",password:"123456"})

  const login_fn = async ()=> {
    const res = await login(markRaw(account))
    if(res.code === 200){
      setToken(res.data.token)
      await userStore.fetchAuths();
      router.push("/")
    }
  }

</script>

<template>
 <div>
   <a-button @click="login_fn">登录</a-button>
 </div>
</template>

<style scoped lang="less">

</style>
